package com.core.dto;

import com.core.model.xg.Excutor;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 *
 * @author lxf
 * @date 2018/5/2 17:27
 * To change this template use Editor | File and Code Templates.
 */
public class ExcutorDTO {

    private String id;
    private String name;

    public ExcutorDTO() {
    }

    public ExcutorDTO(String id, String name) {
        this.id = id;
        this.name = name;
    }

    public static ExcutorDTO toDTO(Excutor excutor) {
        return new ExcutorDTO(excutor.id(), excutor.name());
    }

    public static List<ExcutorDTO> toDTOs(List<Excutor> excutors) {
        List<ExcutorDTO> list = new ArrayList<>();
        for (Excutor e : excutors) {
            list.add(toDTO(e));
        }
        return list;
    }

    public Excutor toExcutor(ExcutorDTO excutorDTO) {
        Excutor e = new Excutor(excutorDTO.getName());
        return e;
    }

    public static Map<String, String> toMaps(List<ExcutorDTO> excutorDTOS) {
        Map<String, String> map = new HashMap<>();
        for (ExcutorDTO e : excutorDTOS) {
            map.put(e.getId(), e.getName());
        }
        return map;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
